<?php
namespace app\controller;

use app\BaseController;
use app\model\ArticleModel;
use think\facade\View;

/**
 * 首页
 */
class Index extends BaseController
{
    public function index()
    {

        // 推荐资讯 属性 0  未推荐  1 推荐到首页大图 2 推荐到首页要闻 3 推荐到首页列表小图
        $rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'flag' => 1,
        ];
        $rec_list = ArticleModel::where($rec_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('rec_list', $rec_list);

        // 热门资讯 flag = 2
        $hot_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'flag' => 2,
        ];
        $hot_list = ArticleModel::where($hot_where)->order('show_time', 'desc')->limit(3)->select();
        View::assign('hot_list', $hot_list);

        //////////////////// 板块一 ////////////////////
        // 留学就业  5 --- 改为 国际人才 22
        $lxjy_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 22,
        ];
        $lxjy_list = ArticleModel::where($lxjy_where)->order('show_time', 'desc')->limit(6)->select();
        View::assign('lxjy_list', $lxjy_list);


        // 政策解读
        $zcjd_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 3,
        ];
        $zcjd_list = ArticleModel::where($zcjd_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('zcjd_list', $zcjd_list);

        // 政策解读 推荐的
        $zcjd_rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 3,
            'flag' => 3,
        ];
        $zcjd_rec_list = ArticleModel::where($zcjd_rec_where)->order('show_time', 'desc')->find();
        View::assign('zcjd_rec_list', $zcjd_rec_list);

        // 留学资讯 4 ==== 人才交流 4 查 所有子栏目 in(20,21,22)
        $lxzx_where = [
            'deleted' => 0,
            'status_flag' => 0,
//            'catid' => 4,
//            'catid' => ['in', '20,21,22'],
        ];
        $lxzx_list = ArticleModel::where($lxzx_where)->where('catid','in','20,21,22')->order('show_time', 'desc')->limit(5)->select();
        View::assign('lxzx_list', $lxzx_list);

        // 留学资讯推荐
        $lxzx_rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'flag' => 3,
        ];
        $lxzx_rec_list = ArticleModel::where($lxzx_rec_where)->where('catid','in','20,21,22')->order('show_time', 'desc')->find();
        View::assign('lxzx_rec_list', $lxzx_rec_list);




        //////////////////// 板块二 ////////////////////

        // 人才交流  6 改为 最新动态
        $rcjl_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 6,
        ];
        $rcjl_list = ArticleModel::where($rcjl_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('rcjl_list', $rcjl_list);



        // 11 招生简章 11 改为 校企合作专委会 9
        $zsjz_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 9,
        ];
        $zsjz_list = ArticleModel::where($zsjz_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('zsjz_list', $zsjz_list);

        // 招生简章 11 推荐 校企合作专委会 9
        $zsjz_rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 9,
            'flag' => 3,
        ];
        $zsjz_rec_list = ArticleModel::where($zsjz_rec_where)->order('show_time', 'desc')->find();
        View::assign('zsjz_rec_list', $zsjz_rec_list);


        // 12 申请攻略  改为 班墨计划专委会 10
        $sqgl_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 10,
        ];
        $sqgl_list = ArticleModel::where($sqgl_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('sqgl_list', $sqgl_list);

        // 申请攻略 推荐
        $sqgl_rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 10,
            'flag' => 3,
        ];
        $sqgl_rec_list = ArticleModel::where($sqgl_rec_where)->order('show_time', 'desc')->find();
        View::assign('sqgl_rec_list', $sqgl_rec_list);


        // 13 留学生活 改为  智库  12
        $lxsh_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 12,
        ];
        $lxsh_list = ArticleModel::where($lxsh_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('lxsh_list', $lxsh_list);

        // 14 留学生活 推荐
        $lxsh_rec_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 12,
            'flag' => 3,
        ];
        $lxsh_rec_list = ArticleModel::where($lxsh_rec_where)->order('show_time', 'desc')->find();
        View::assign('lxsh_rec_list', $lxsh_rec_list);




        //////////////////// 板块三 ////////////////////

        // 9 留学院校 改为 人才孵化 11
        $lxyx_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 11,
        ];
        $lxyx_list = ArticleModel::where($lxyx_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('lxyx_list', $lxyx_list);

        // 10 留学专业 生涯规划 14
        $lxzy_where = [
            'deleted' => 0,
            'status_flag' => 0,
            'catid' => 14,
        ];
        $lxzy_list = ArticleModel::where($lxzy_where)->order('show_time', 'desc')->limit(5)->select();
        View::assign('lxzy_list', $lxzy_list);


        return View::fetch();
    }

}
